package com.api.shopapi.mapper;


import com.api.shopapi.entity.CartBusiness;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface CartBusinessMapper {

    @Insert("insert into cart_business " +
            "(" +
            "CartBusinessCode," +
            "CartCode," +
            "Price," +
            "BusinessCode," +
            "GoodsType" +
            ")" +
            "values" +
            "(" +
            "#{cartBusiness.CartBusinessCode}," +
            "#{cartBusiness.CartCode}," +
            "#{cartBusiness.Price}," +
            "#{cartBusiness.BusinessCode}," +
            "#{cartBusiness.GoodsType}" +
            ")")
    public int insert(@Param("cartBusiness") CartBusiness cartBusiness);

    @Update("update cart_business set " +
            "CartCode = #{cartBusiness.CartCode}," +
            "Price=#{cartBusiness.Price}," +
            "BusinessCode=#{cartBusiness.BusinessCode}," +
            "GoodsType=#{cartBusiness.GoodsType}" +
            " where CartBusinessCode=#{cartBusiness.CartBusinessCode}")
    public int update(@Param("cartBusiness") CartBusiness cartBusiness);

    @Delete("delete from cart_business where CartBusinessCode=#{cartBusinessCode}")
    public int delete(@Param("cartBusinessCode") String cartBusinessCode);

    @Select("select * from cart_business")
    public List<CartBusiness> getList();

    @Select("select * from cart_business where CartBusinessCode=#{cartBusinessCode} limit 1")
    public CartBusiness getByCartBusinessCode(@Param("cartBusinessCode") String cartBusinessCode);


    @Select("select * from cart_business where cartCode=#{cartCode}")
    public List<CartBusiness> getListByCartCode(String cartCode);



}
